import React, { useEffect, useState, useRef } from 'react';
import { View, Button, Input, Text } from '@tarojs/components'
import PopUp from '@/components/PopUp'
import './index.scss';
const DrawerRadio = (props) => {
    const { visible = {}, onClose, data = {}, onChange } = props
    const { show = false, detail = {}, title } = visible
    const { fieldConditions = {}, value, require } = detail
    const { listName } = fieldConditions
    return <PopUp title={title} {...props}>
        <View onClick={(e) => {
            e.stopPropagation()
        }} className='DrawerRadio_check_list'>
            {detail[listName] && detail[listName].map(val => {
                return <View onClick={(e) => {
                    if (val[fieldConditions['value']] !== data[value]) {
                        onChange({
                            [value]: val[fieldConditions['value']]
                        })
                        onClose()
                    } else {
                        if (require === '1') {
                            return
                        }
                        onChange({
                            [value]: ''
                        })
                        onClose()
                    }
                }} className={data[value] === val[fieldConditions['value']] ? 'DrawerRadio_check_val DrawerRadio_check_valCheck' : 'DrawerRadio_check_val'}>
                    {val[fieldConditions['label']]}
                </View>
            })}
        </View>
    </PopUp>
}
export default DrawerRadio